Branchwell

AI Resource Pro / website · airesourcepro.com / src / app / [track] / page.tsx

1import type { Metadata } from "next";
2import Image from "next/image";
3import { notFound } from "next/navigation";
4import { JsonLd } from "@/components/json-ld";
5import { PageIntro } from "@/components/page-intro";
6import { FeaturedTutorials, TutorialRows } from "@/components/tutorial-card";
7import { breadcrumbJsonLd, collectionJsonLd, ogImageFor, pageMetadata } from "@/lib/seo";
8import { TRACKS, getTrack } from "@/lib/tracks";
9import { getTutorialsByTrack, type Level } from "@/lib/tutorials";
10
11export const dynamicParams = false;
12
13export function generateStaticParams() {
14 return TRACKS.map((t) => ({ track: t.slug }));
15}
16
17type Props = { params: Promise<{ track: string }> };
18
19export async function generateMetadata({ params }: Props): Promise<Metadata> {
20 const track = getTrack((await params).track);
21 if (!track) return {};
22 return pageMetadata({
23 title: `${track.name} tutorials`,
24 description: `${track.tagline}. ${track.description}`,
25 path: `/${track.slug}`,
26 image: ogImageFor(`/covers/${track.slug}.webp`),
27 });
28}
29
30const LEVELS: Level[] = ["Beginner", "Intermediate", "Advanced"];
31
32export default async function TrackPage({ params }: Props) {
33 const track = getTrack((await params).track);
34 if (!track) notFound();
35 const tutorials = getTutorialsByTrack(track.slug);
36
37 return (
38 <div className="page" style={{ "--tc": track.color } as React.CSSProperties}>
39 <JsonLd
40 data={[
41 breadcrumbJsonLd([
42 { name: "Home", path: "/" },
43 { name: track.name, path: `/${track.slug}` },
44 ]),
45 collectionJsonLd({
46 name: `${track.name} tutorials`,
47 description: track.description,
48 path: `/${track.slug}`,
49 tutorials: tutorials.filter((t) => !t.draft),
50 }),
51 ]}
52 />
53 <div className="grid items-center gap-10 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)] lg:gap-16">
54 <PageIntro
55 label={`${track.tagline} · ${tutorials.length === 1 ? "1 tutorial" : `${tutorials.length} tutorials`}`}
56 title={track.name}
57 lead={track.description}
58 color={track.color}
59 />
60 <div className="relative aspect-[5/3] overflow-hidden rounded-3xl border border-border shadow-[0_30px_80px_-30px_var(--card-glow)]">
61 <Image src={`/covers/${track.slug}.webp`} alt="" fill priority sizes="(min-width: 1024px) 620px, 100vw" className="object-cover" />
62 </div>
63 </div>
64
65 <div className="tutorial-prose mt-14 max-w-3xl">
66 {track.intro.map((paragraph) => (
67 <p key={paragraph}>{paragraph}</p>
68 ))}
69 </div>
70
71 {tutorials.length === 0 && <p className="mt-16 text-[var(--ash)]">Tutorials for this track are on the way.</p>}
72
73 <FeaturedTutorials tutorials={tutorials.filter((t) => t.video)} className="mt-20" />
74
75 {LEVELS.map((level) => {
76 const items = tutorials.filter((t) => t.level === level && !t.video);
77 if (items.length === 0) return null;
78 return (
79 <section key={level} className="mt-20">
80 <h2 className="label mb-6">
81 <i />
82 {level}
83 </h2>
84 <TutorialRows tutorials={items} />
85 </section>
86 );
87 })}
88 </div>
89 );
90}